

#pragma once
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/timestamp.h>
#include <libavutil/threadmessage.h>
#include <libavcodec/packet.h>
#include <libavfilter/avfilter.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavfilter/buffersrc.h>
#include <libavfilter/buffersink.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>

};
#include <cstring>
#include <string>
#include <vector>
#include <functional>
#include <iostream>
#include <memory>
#include "message_queue.h"
#include "input_output_context.h"
#include "filter_graph_context.h"


void ReadPacketDataToMessageQueue(InputFormatContext * input_format_ctx, AVPacket * packet, PacketMessageQueue & packet_message_queue);
void ReadPacketDataCallback(InputFormatContext * input_format_ctx, std::function<bool(InputFormatContext *, AVPacket * )> && function_callback);
void ReadPacketDataWithCallback(InputFormatContext * input_format_ctx, AVPacket * packet, std::function<bool(InputFormatContext *, AVPacket * )> && function_callback);

bool DecodePacketDataToMessageQueue(DecoderContext * codec_ctx, AVPacket * packet, FrameMessageQueue  & frame_message_queue);
bool DecodePacketDataToMessageQueue(std::shared_ptr<DecoderContext> codec_ctx, AVPacket * packet, FrameMessageQueue  & frame_message_queue);
bool DecodePacketDataToQueue(std::shared_ptr<DecoderContext> codec_ctx, AVPacket * packet, FrameMessageQueue & frame_message_queue);

void ProcessPacketDataFromMessageQueue(PacketMessageQueue & message_queue, std::function<void(AVPacket * packet)> && process_func, bool eof_break);
void ProcessFrameDataFromMessageQueue(FrameMessageQueue   & message_queue, std::function<void(AVFrame  * frame)>  && process_func, bool eof_break);

bool EncodeFrameDataToMessageQueue(std::shared_ptr<EncoderContext> codec_ctx, AVFrame * frame, PacketMessageQueue & message_queue);
bool EncodeFrameDataToMessageQueue(EncoderContext * codec_ctx, AVFrame * frame, PacketMessageQueue & message_queue);

bool FilterFrame(FilterGraphContext * filter_graph, AVFrame * frame, FrameMessageQueue & message_queue);



